-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[client] Adds signWithEckoWallet and quicksignWithEckoWallet functions #750
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 5 Ignored Deployments
|
598b7c3
to
e7c03ec
Compare
if (checkStatusResponse?.status === 'fail') { | ||
return false; | ||
} | ||
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best way to check for active status or should we return true on a positive signal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although Ecko returns a fail
status when it isn't connected, I agree that it might be better to turn things around to only return true
when the returned status is success
. Then it'll also return false when Ecko returns capybara
or something else that's just weird.
await window.kadena?.request<IEckoConnectOrStatusResponse>({ | ||
method: 'kda_connect', | ||
networkId, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this ever throw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only when request
doesn't exist on window.kadena
, which is checked in isConnected
. I've now added an extra check in that function to check if window.kadena.request
is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM aside from two small questions
3a5f6fb
to
7aeda2a
Compare
*/ | ||
export interface IEckoSignSingleFunction | ||
extends ISingleSignFunction, | ||
ICommonEckoFunctions {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mixing a function with properties might lead to a confusing api for users since function itself has some methods like apply, call ,...
what if we instead add the sign as a method like this
export interface IEckoSignFunction {
isInstalled: typeof isInstalled;
isConnected: typeof isConnected;
connect: typeof connect;
sign : ISingleFunction,
quickSign : ISingleFunction,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've thought about that, but we wanted to make the usage of this function the same as the other functions to allow drop-in replacement.
Maybe instead of exposing export interface IEckoWalletConnector {
isInstalled: () => boolean;
isConnected: (networkId:string) => Promise<boolean>;
connect: (networkId:string) => Promise<boolean>;
sign : ISingleSignFunction,
quickSign : ISignFunction,
}
const echoWalletConnector: IEckoWalletConnector = createEchoWalletConnector(); What do you say @alber70g |
There are multiple things at hand here
|
add6eb5
to
9a1f564
Compare
common/changes/@kadena/client/feat-signWithEckoWallet_2023-08-08-11-29.json
Outdated
Show resolved
Hide resolved
9a1f564
to
9e78532
Compare
9e78532
to
d938330
Compare
Do we still want to merge this pull request? |
3803545
to
3304085
Compare
🦋 Changeset detectedLatest commit: 8748d4b The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
3304085
to
8748d4b
Compare
Adds two functions to sign a transaction with the Ecko Wallet API.
Usage, where
unsignedTransaction
is aIPactCommand
:On both
signWithEckoWallet
andquicksignWithEckoWallet
there are several helpers available:connect()
is also automatically called when signing for a transaction